﻿class cn.eminia.AS2.MC_VV {
	function MC_VV( id:Number ,a:String, b:String) {
		var aa = a.split(',');
		var bb = b.split(',');
		if(!_root.MC_VV_vv)_root.MC_VV_vv=[]
		if (aa.length != bb.length) throw new Error('!!! Length NOT equal');
		_root.MC_VV_vv[id]=[aa,bb];
	}
	static function getVV(id,cc){
		var oo=_root.MC_VV_vv[id]						//trace('oo '+oo);
		//reduceScope And getVV
		var aa=oo[0]
		var bb=oo[1]
		//trace(cc+ '  ' +aa[0]+(cc<aa[0]))
		if(cc<aa[0]) 					return bb[0]			//trace('当前位置:小于最小'+aa[0])
		if(cc>aa[aa.length-1])  		return bb[bb.length-1]	//trace('当前位置:大于最大'+aa[aa.length-1])
		for(var i=0;i<aa.length;i++)	{
		//trace([bb[i],bb[i+1],aa[i],aa[i+1]])
		if(cc>aa[i]&&cc<aa[i+1]||cc==aa[i+1]) return getVVBase([int(bb[i]),int(bb[i+1])],[int(aa[i]),int(aa[i+1])],cc)	//trace('当前位置:'+aa[i]+' - '+aa[i+1])
		}
	}
	static function getVVBase(a, b, c) {
		return (a[0]-a[1])*(c-b[1])/(b[0]-b[1])+a[1];
	}
}
